@extends("admin.layout.main")

@section("content")
    <style>
        .error {
            color: red;
        }

        #container {
            width: 70%;
            height: 400px;
        }

        #pickerBox {
            width: 500px;
        }

        #poiInfo {
            background: #fff;
        }

        #selectCity a {
            margin-right: 5px;
        }
    </style>

    <!--富文本编辑器-->
    <link href="/plugins/kindeditor/themes/default/default.css" media="screen" rel="stylesheet" type="text/css">
    <link href="/plugins/kindeditor/plugins/code/prettify.css" media="screen" rel="stylesheet" type="text/css">

    <script src="/plugins/kindeditor/kindeditor-all.js" type="text/javascript"></script>
    <script src="/plugins/kindeditor/lang/zh-CN.js" type="text/javascript"></script>
    <script src="/plugins/kindeditor/plugins/code/prettify.js" type="text/javascript"></script>

    <!--主页面头部信息-->
    <div class="page-header">
        <h1>
            文章管理
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form class="form-horizontal" method="post" id="form" action="{{ route('admin.article.ajaxSave') }}">
                <input type="hidden" name="id" value="{{ $data->id }}">
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 文章名称: </label>
                    <div class="col-sm-9" style="margin-top: 9px">
                        成为城市合伙人
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label no-padding-right"> 文章内容: </label>
                    <div class="col-sm-9">
                        <textarea style="width:634px;height:500px;visibility:hidden;" name="content" id="content" aria-required="true">{{ $data->content }}</textarea>
                    </div>
                </div>
                <div class="col-md-offset-2 col-md-9">
                    <button class="btn btn-info btn-primary">
                        保存
                    </button>
                    <a class="btn" type="button" onclick="javascript:history.back(-1);">
                        取消
                    </a>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        $('#descript').keyup(function () {
            var curLength = $(this).val().length;
            $('#desplength').html(curLength);
        });
        KindEditor.ready(function (K) {
            var editor1 = K.create('textarea[name="content"]', {
                urlType: 'domain',
                afterBlur: function () {
                    this.sync();
                },
                afterChange: function () {
                    $('.word_count1').html(this.count()); //字数统计包含HTML代码
                    $('.word_count2').html(this.count('text'));  //字数统计包含纯文本、IMG、EMBED，不包含换行符，IMG和EMBED算一个文字
                    //////////
                    //限制字数
                    var limitNum = 700;  //设定限制字数
                    var pattern = '还可以输入' + limitNum + '字';
                    $('#content_length').html(pattern); //输入显示
                    // if(this.count('text') > limitNum) {
                    //     pattern = ('<span style="color:red">字数超过限制</span>');
                    //     //超过字数限制自动截取
                    //     var strValue = editor1.text();
                    //     strValue = strValue.substring(0,limitNum);
                    //     editor1.text(strValue);
                    // } else {
                    //     //计算剩余字数
                    //     var result = limitNum - this.count('text');
                    //     pattern = '还可以输入' +  result + '字';
                    // }
                    $('#content_length').html(pattern); //输入显示
                    ////////
                }

            });
        });
    </script>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
@endsection
